config = require('../config')
Schema = config.Schema
mongoose = config.mongoose

###
  Schema = config.Schema
mongoose = config.mongoose
###
DictSchema = new Schema({
  key_code  :
    type : String
    required : true
    unique : true
  key_name  :
    type : String
    required : true
  key_value : String
  key_desc : String
  parent_code :
    type : String
    default : 'root'
})

DictSchema.methods.add =  (req,cb) ->
  this.parent_code = req.param('parent_code')
  this.key_code = req.param('key_code')
  this.key_name = req.param('key_name')
  this.key_desc = req.param('key_desc')
  this.key_value = req.param('key_value')
  this.save cb

exports.Dict = mongoose.model 'Dict', DictSchema